<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

       




        function axios(options) {
            return new Promise((resolve, reject) => {
                var xhr = new XMLHttpRequest() // 实例化一个ajax对象
                xhr.open(options.method, options.url, options.async)
                // xhr.setRequestHeader("", "");//设置 http  头信息
                xhr.send()
                xhr.onreadystatechange = function() {
                    if(xhr.readyState === 4 && xhr.status === 200) {
                        let data = xhr.responseText
                        console.log(data)
                        resolve(data)
                    }
                }   
            })
        }

        axios.get = function(url) {
            return new Promise((resolve, reject) => {
                var xhr = new XMLHttpRequest() // 实例化一个ajax对象
                xhr.open('get', url, true)
                // xhr.setRequestHeader("", "");//设置 http  头信息
                xhr.send()
                xhr.onreadystatechange = function() {
                    if(xhr.readyState === 4 && xhr.status === 200) {
                        let data = xhr.responseText
                        resolve(JSON.parse(data))
                    }
                }   
            })
        }

        // axios({
        //     url: 'https://locally.uieee.com/slides',
        //     method: 'get',
        //     async: true,
        // }).then(res => {
        //     console.log(res)
        // })  



        axios.get('https://locally.uieee.com/slides').then(res =>{
            console.log(res)
        })
    </script>
</body>
</html>